<template>
	<view>
		<u-sticky bgColor="#fafafa">
			<view class="mainpadding" style="position: relative; z-index: 2;">
				<view class="ffffff flexbetween ssbox">
					<view class="flexleft">
						<u-icon name="search" color="#999" size="20"></u-icon>
						<input type="text" placeholder="请输入搜索内容" class="hei_text main_size bold" v-model="keywords" @confirm="init" confirm-type="search">
					</view>
					<view class="rightss">搜索</view>
				</view>
			</view>
		</u-sticky>
		<view class="mainpadding">
			<view class="pdl flexleft" v-for="item in list.data" :key="item.id" @click="jumpurl('/pages/zixun/detail?id=',item.id)">
				<view class="listleftimg">
					<image :src="item.image_text" class="listleftimg" mode=""></image>
				</view>
				<view class="flexcolumnbet margin_left" style="height: 160rpx;">
					<view class="titletext bold yihang">{{item.name}}</view>
					<view class="hui_text main_size yihang">{{item.des}}</view>
					<view class="xiaohui flexright" style="width: 100%;">
						<text class="margin_right">{{item.createtime_text}}</text>
						<u-icon name="eye" color="#999" size="16"></u-icon>
						<text>{{item.look_num}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: [],
				},
				keywords:""
			}
		},
		onShow() {
			this.init()
		},
		onShareAppMessage: function(options) {
			return {
				title: '制片宝',
				imageUrl: '',
				path: '/pages/index/index'
			}
		},
		onShareTimeline: function() {
			return {
				title: '制片宝',
				imageUrl: '',
				path: '/pages/index/index'
			}
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				httpRequest.request("index/zxIndex", 'GET', {
					page: page || 1,
					limit: _this.limit,
					keywords:this.keywords
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							_this.list = resList
							_this.list.data = resList.data;
						}
						this.pageshow = true
					}
					uni.hideLoading()
				}).catch(err => {
					uni.hideLoading()
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumpurl(url,id){
				uni.navigateTo({
					url:url+id
				})
			},
		}
	}
</script>

<style>

</style>
